<template>
	<view class="">
		<view class="foot-tavbar-container d-a-c" :style="'background:#ffffff;' ">
			<!-- <view v-if="platform != 'wx' || (item.is_show && platform == 'wx')" class="item d-c-c" :class="{'active':item.text===activeTabber}" v-for="(item, index) in detail.list" :key="index" @tap="tabBarFunc(item)">
				<view class="inner d-c-c d-c">
					<image :src="item.text===activeTabber?item.selectedIconPath:item.iconPath" mode="aspectFill" v-if="item.type!=2"></image>
					<text :style="item.text==activeTabber?'color:'+detail.textHoverColor+';':'color:'+detail.textColor+';'" class="text-name" v-if="item.type!=1">{{ item.text}}</text>
				</view>
			</view> -->

			<!-- 车主端 -->
			<!-- <view class="item d-c-c" :class="{'active':item.text===activeTabber}" v-for="(item, index) in navList"
				:key="index" @tap="tabBarFunc(item)">
				<view class="inner d-c-c d-c">
					<image :src="item.text===activeTabber?item.selectedIconPath:item.iconPath" mode="aspectFill"
						v-if="item.type!=2"></image>
					<text :style="item.text==activeTabber?'color:#636EFD;':'color:#333333;'" class="text-name"
						v-if="item.type!=1">{{ item.text}}</text>
				</view>
			</view> -->

			<!-- 用户端 -->
			<view class="item d-c-c" :class="{'active':item.text===activeTabber}" v-for="(item, index) in userList"
				:key="index" @tap="tabBarFunc(item)" v-if="user_type == 2">
				<view class="inner d-c-c d-c">
					<image :src="item.text===activeTabber?item.selectedIconPath:item.iconPath" mode="aspectFill"
						v-if="item.type!=2"></image>
					<text :style="item.text==activeTabber?'color:#0C2D3E;':'color:#B4BDC2;'" class="text-name"
						v-if="item.type!=1">{{ item.text}}</text>
				</view>
			</view>
			<view class="item d-c-c" :class="{'active':item.text===activeTabber}" v-for="(item, index) in navList"
				:key="index" @tap="tabBarFunc(item)" v-if="user_type == 1">
				<view class="inner d-c-c d-c">
					<image :src="item.text===activeTabber?item.selectedIconPath:item.iconPath" mode="aspectFill"
						v-if="item.type!=2"></image>
					<text :style="item.text==activeTabber?'color:#5864FD;':'color:#0C2D3E;'" class="text-name"
						v-if="item.type!=1">{{ item.text}}</text>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		gotopage
	} from '@/common/gotopage.js'

	export default {
		data() {
			return {
				/*当前选中*/
				activeTabber: '首页',
				/*打开直播菜单*/
				open_liveMenu: false,
				/*底部菜单*/
				detail: {},
				/*是否微信小程序*/
				platform: 'wx',
				/* 用户类别 1为车主端 2为用户端 */
				user_type: 2,
				/* 用户端首页 */
				userTabber: '首页',
				// navList: [{
				// 		iconPath: "/static/app/nav/nav1-01.png",
				// 		is_show: true,
				// 		link: {
				// 			wap_url: "/pagesUser/home/home",
				// 		},
				// 		selectedIconPath: "/static/app/nav/nav1-02.png",
				// 		text: "首页"
				// 	},
				// 	{
				// 		iconPath: "/static/app/nav/nav2-01.png",
				// 		is_show: true,
				// 		link: {
				// 			wap_url: "/pagesUser/journey/journey",
				// 		},
				// 		selectedIconPath: "/static/app/nav/nav2-02.png",
				// 		text: "福利"
				// 	},
				// 	{
				// 		iconPath: "/static/app/nav/nav3-01.png",
				// 		is_show: true,
				// 		link: {
				// 			wap_url: "/pagesUser/information/information",
				// 		},
				// 		selectedIconPath: "/static/app/nav/nav3-02.png",
				// 		text: "招聘司机"
				// 	},
				// 	{
				// 		iconPath: "/static/app/nav/nav4-01.png",
				// 		is_show: true,
				// 		link: {
				// 			wap_url: "/pages/violation/violation",
				// 		},
				// 		selectedIconPath: "/pagesUser/user/index/index",
				// 		text: "处理违章"
				// 	},
				// 	{
				// 		iconPath: "/static/app/nav/nav5-01.png",
				// 		is_show: true,
				// 		link: {
				// 			wap_url: "/pages/user/index/index",
				// 		},
				// 		selectedIconPath: "/pagesUser/user/index/index",
				// 		text: "我的"
				// 	},
				// ],
				userList: [{
						iconPath: "/static/user/idx1.png",
						is_show: true,
						link: {
							wap_url: "/pagesUser/home/home",
						},
						selectedIconPath: "/static/user/idx2.png",
						text: "首页"
					},
					{
						iconPath: "/static/user/ju1.png",
						is_show: true,
						link: {
							wap_url: "/pagesUser/journey/journey",
						},
						selectedIconPath: "/static/user/ju2.png",
						text: "行程"
					},
					{
						iconPath: "/static/user/msg1.png",
						is_show: true,
						link: {
							wap_url: "/pagesUser/information/information",
						},
						selectedIconPath: "/static/user/msg2.png",
						text: "消息"
					},
					{
						iconPath: "/static/user/my1.png",
						is_show: true,
						link: {
							wap_url: "/pagesUser/user/index/index",
						},
						selectedIconPath: "/static/user/my2.png",
						text: "我的"
					}
				],


				navList: [{
						iconPath: "/static/app/nav/nav1-01.png",
						is_show: true,
						link: {
							wap_url: "/pages/home/home",
						},
						selectedIconPath: "/static/app/nav/nav1-02.png",
						text: "首页"
					},
					{
						iconPath: "/static/app/nav/nav2-01.png",
						is_show: true,
						link: {
							wap_url: "/pages/welfare/welfare",
						},
						selectedIconPath: "/static/app/nav/nav2-02.png",
						text: "福利"
					},
					{
						iconPath: "/static/app/nav/nav3-01.png",
						is_show: true,
						link: {
							wap_url: "/pages/recruitment/recruitment",
						},
						selectedIconPath: "/static/app/nav/nav3-02.png",
						text: "招聘司机"
					},
					{
						iconPath: "/static/app/nav/nav4-01.png",
						is_show: true,
						link: {
							wap_url: "/pages/violation/violation",
						},
						selectedIconPath: "/static/app/nav/nav4-02.png",
						text: "处理违章"
					},
					{
						iconPath: "/static/app/nav/nav5-01.png",
						is_show: true,
						link: {
							wap_url: "/pages/user/index/index",
						},
						selectedIconPath: "/static/app/nav/nav5-02.png",
						text: "我的"
					},
				],
			};
		},
		watch: {
			'footTabberData': {
				handler(n, o) {
					if (n != o) {
						this.activeTabber = n.active;
					}
				},
				deep: true,
				immediate: true
			}
		},
		created() {
			let classify = uni.getStorageSync('classify');
			if (classify == 2) {
				this.user_type = 2;
			} else if (classify == 1) {
				this.user_type = 1;
			}
			let pages = getCurrentPages();
			// if (pages.length) {
			// 	let currentPage = pages[pages.length - 1];
			// 	if (currentPage.route == 'pages/index/index') {
			// 		this.activeTabber = '首页';
			// 	}
			// }
			this.platform = this.getPlatform();
			let tabBar = {
				list: this.navList
			};
			uni.setStorageSync('TabBar', tabBar);
			this.detail = uni.getStorageSync('TabBar');

			// this.getData();

		},
		onLoad() {
			//this.getDatainfo();
			let self = this;			
		},
		methods: {
			/*点击菜单*/
			tabBarFunc(e) {
				this.footTabberData.active = e.text;
				gotopage(e.link.wap_url);
			},
			// /*点击菜单*/
			// tabBarFuncUser(e) {
			// 	console.log(this.footTabberDataUser);
			// 	// this.footTabberDataUser.active = e.text;
			// 	// gotopage(e.link.wap_url);
			// },
			gopage(url) {
				uni.redirectTo({
					url: url
				})
			},
			// /*获取首页分类*/
			// getData() {
			// 	let self = this;
			// 	self._get('index/nav', {}, function(res) {
			// 		self.detail = res.data.data;
			// 		uni.setStorageSync('TabBar', res.data.data);
			// 	});
			// },
			// /*获取数据*/
			// getDatainfo() {
			// 	let self = this;
			// 	uni.showLoading({
			// 		title: '加载中'
			// 	});
			// 	self._get('user.index/detail', {}, function(res) {
			// 		self.user_type = res.data.userInfo.user_type;
			// 		self.loadding = false;
			// 		uni.hideLoading();
			// 	});
			// },
		}
	};
</script>

<style lang="scss">
	.foot-tavbar-container {
		box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, 0.3);
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		height: 98rpx;
		background: #2c2c2c;
		z-index: 90;
	}

	.foot-tavbar-container .item {
		flex: 1;
		height: 98rpx;
	}

	.foot-tavbar-container .item.add-btn .inner {
		margin-bottom: 70rpx;
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		background: $dominant-color;
		box-shadow: 0 0 10rpx 0 rgba(232, 38, 100, .6);
	}

	.foot-tavbar-container image {
		width: 50rpx;
		height: 50rpx;
	}

	.foot-tavbar-container .text-name {
		font-size: 24rpx;
		color: #666666;
	}

	.foot-tavbar-container .item.active .text-name {
		color: #f8c341;
	}
</style>
